<style>
  .text-center {
    text-align: left !important;
    width: 100px !important;
  }
</style>
<form id="" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
  {if condition="(count($attr_group_list) == 0)"}
  <div class="form-group">
    <label class="control-label col-xs-12 col-sm-2"></label>
    <label class="control-label col-xs-12 col-sm-4">暂无年级/班级, 请添加</label>
  </div>
    {else /}
  <div class="form-group">
    <label class="control-label col-xs-12 col-sm-2">年级/班级信息：</label>
  </div>
  <div class="form-group">
    <label class="control-label col-xs-12 col-sm-2">
      <input name="全选" type="checkbox" onclick="changeState(this.checked)" /> 全选
    </label>

    <label class="control-label col-xs-12 col-sm-9">
      <a href="javascript:;" id="submit" class="btn btn-success">添加课程</a>
      <a href="javascript:;" id="look" class="btn btn-primary">查看课程</a>
    </label>


  </div>
  {foreach name="attr_group_list" item="group"}
  <div class="form-group">
    <label class="control-label col-xs-12 col-sm-2">
<!--      <input id="c-use_attr-cancel" name="row[use_attr]" type="checkbox" /> -->
      {$group.attr_group_name}
    </label>
  </div>
  <div class="form-group">
    <label class="control-label col-xs-12 col-sm-2"></label>
    {foreach name="$group['attr_list']" item="attr"}
    <label class="control-label col-xs-12 col-sm-2 text-center">
      <input name="add_attr" type="checkbox" value="{$attr.attr_id}" /> {$attr.attr_name}
    </label>
    {/foreach}
  </div>
  {/foreach}
  {/if}
  <div class="form-group" style="margin:100px 0 0 20%">
    <a href="javascript:;" id="edit_class" class="btn btn-info">编辑年级/班级</a>
  </div>
</form>
<script src="/assets/libs/jquery/dist/jquery.min.js"></script>
<script>
  function changeState(isChecked)
  {
    var chk_list=document.getElementsByTagName("input");
    for(var i=0;i<chk_list.length;i++)
    {
      if(chk_list[i].type=="checkbox")
      {
        chk_list[i].checked=isChecked;
      }
    }
  }

  $('#edit_class').click(function () {
    Fast.config.openArea = ['100%', '100%'];
    Fast.api.open('grade/edit', '编辑年级/班级', {
      callback:function(data) {
        alert(111)
      }
    });
  });

  $('#submit').click(function () {
    var chk_value = [];
    $('input[name="add_attr"]:checked').each(function(){
      chk_value.push($(this).val());
    });

    if (chk_value.length == 0) {
      layer.alert('请选择班级', {
        icon: 5
      })
      return
    }
    Fast.config.openArea = ['100%', '100%'];
    Fast.api.open('goods/classadd/index?add_attr='+chk_value, '添加课程');
  })

  $('#look').click(function () {
    var chk_value = [];
    $('input[name="add_attr"]:checked').each(function(){
      chk_value.push($(this).val());
    });

    if (chk_value.length == 0) {
      layer.alert('请选择要查看的班级', {
        icon: 5
      })
      return
    }
    Fast.config.openArea = ['100%', '100%'];
    Fast.api.open('grade/look?add_attr='+chk_value, '查看课程');
  })
</script>
